<?php


namespace App\Dao;


use App\Model\AdminRole;

class AdminRoleDao extends AbstractDao
{

    /**
     * @param array $where
     * @return \Hyperf\Database\Concerns\BuildsQueries|\Hyperf\Database\Model\Builder|mixed
     */
    public function where(array $where): \Hyperf\Database\Model\Builder
    {
        $query = $this->query();
        foreach($where as $field=>$value){
            switch ($field){
                case 'not_show_default':
                    $query->where('name','<>',config('menus.default_admin_role.name'));
                    break;
                default:
                    $query->where($field,$value);

            }
        }
        return $query;
    }


    /**
     * @return \Hyperf\Database\Model\Builder
     */
    public function query(): \Hyperf\Database\Model\Builder
    {
        return AdminRole::query();
    }
}